#ifndef _SERVER_PROTOCOL_H
#define _SERVER_PROTOCOL_H


#include <cedule/frame.h>

typedef enum {
	PROTOCOL_STATE_NONE,
	PROTOCOL_STATE_ERROR,
	PROTOCOL_STATE_INIT_OK,
	PROTOCOL_STATE_RUNNING,
	PROTOCOL_STATE_CONNECT, /* client connected */
	PROTOCOL_STATE_AUTHREQ, /* client requested auth */
	PROTOCOL_STATE_AUTH_OK, /* client successfully authentified */
} Protocol_State_t;

typedef struct protocol_t {
	Frame_t * frames_in;
	Frame_t * frames_out;
	Protocol_State_t state;
} Protocol_t;

/*
Protocol_Frame_t* protocol_frame_new ( );
void protocol_frame_delete( Protocol_Frame_t * frame );


int protocol_frame_is_pending( Protocol_t* proto );
Protocol_Frame_t * protocol_frame_pop( Protocol_t* proto );
int protocol_frame_push( Protocol_t* proto, Protocol_Frame_t * frame );
*/

/* server/protocol.c */
Protocol_t *protocol_create();
void protocol_destroy( Protocol_t* proto );
Frame_t *protocol_frame_pop(Protocol_t *proto);

int protocol_parse( Protocol_t* proto, Frame_t * frame );
int protocol_frame_push(Protocol_t *proto, Frame_t *frame);
int protocol_frame_is_pending(Protocol_t *proto);
#endif
